package com.son.service;

import com.son.dao.InterStudentDao;
import com.son.dao.StudentDaoImpl;
import com.son.domin.Student;
import com.son.factory.StudentFactory;

import java.util.ArrayList;

public class StudentServiceImpl implements InterStudenService{
    private InterStudentDao interStudentDao= StudentFactory.getStudentDao();
    //添加学生
    @Override
    public void addStudent(Student student) {
        interStudentDao.addStudent(student);
    }
//判断学号是否存在
    @Override
    public boolean isExists(String sid) {
       ArrayList<Student> list=interStudentDao.findAllStudent();
        for (int i = 0; i < list.size(); i++) {
            Student student = list.get(i);
            if (student!=null&&student.getSid().equals(sid)){
                return true;
            }
        }
        return false;
    }
//查看学生
    @Override
    public ArrayList<Student> findAllStudent() {
        return interStudentDao.findAllStudent();
    }
//删除学生
    @Override
    public void deleteStudent(String sid) {
interStudentDao.deleteStudent(sid);
    }
//修改学生
    @Override
    public void updateStudent(String sid, Student student) {
interStudentDao.updateStudent(sid,student);
    }
}
